<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.bootcss.com/jquery/1.8.1/jquery.min.js"></script>
<script>
	$(function() {
		$("#username").blur(function() {

			var username = $(this).val();
			$.ajax({
				url : "checkName.do",
				data : {
					username : username
				},
				success : function(data) {
					if (data == 0) {
						$("#msg").text("用户名可用");
					} else {
						$("#msg").text("用户名已存在");
					}
				}
			})
		})
	})
</script>

</head>

<body>
	<table>
		<tr>
			<td>用户名</td>
			<td><input id="username" name="username" /></td>
			<td id="msg"></td>
		</tr>
	</table>
</body>

</html>

